package day07;

//空心菱形
public class Diamond2 {
    public static void main(String[] args) {
        drawDiamond(19);
        drawDiamond2(18);
    }

    //打印上半菱形,菱形边长
    public static void drawDiamond(int len) {
        String temp = " ";
        // String cha=Character.toString('\u26E4');
        for (int i = 1; i <= len; i++) {//外层循环控制行

            for (int j = len; j > i - 1; j--) {//内层循环控制列 6 5 4 3 2 1     5 4 3 2 1   4 3 2 1  3 2 1  2 1  1
                System.out.print(temp);
            }
            for (int j = 1; j <= 2 * i - 1; j++) {//内层循环控制列
                if(j!=1 && j!=2*i-1){
                    System.out.print(temp);
                }else
                System.out.print("*");
            }
            System.out.println();
        }
    }

    //打印下半菱形,少打一行
    public static void drawDiamond2(int len) {
        String temp = " ";
        //String cha=Character.toString('\u26E4');
        for (int i = 1; i <= len; i++) {//外层循环控制行
            for (int j = 1; j <= i + 1; j++) {//内层循环控制列
                System.out.print(temp);
            }
            for (int j = 2 * len - 1; j >= 2 * i - 1; j--) {
                if(j!=2*len-1 && j!=2*i-1){
                    System.out.print(temp);
                }else
                System.out.print("*");
            }
//            for(int j=1;j<=2*len-(2*i-1);j++){//内层循环控制列
//                System.out.print("*");
//            }
            System.out.println();
        }
    }
}
